package com.lw.smartdevice.service.impl;

import com.lw.smartdevice.mapper.SysMenuMapper;
import com.lw.smartdevice.pojo.SysMenu;
import com.lw.smartdevice.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/3/27 17:40
 */
@Service
public class SysMenuServiceImpl implements SysMenuService {

    private SysMenuMapper sysMenuMapper;

    @Autowired
    public void setSysMenuMapper(SysMenuMapper sysMenuMapper) {
        this.sysMenuMapper = sysMenuMapper;
    }

    @Override
    public List<SysMenu> findAllMenu() {
        return sysMenuMapper.findAll() ;
    }

    @Override
    public List<SysMenu> findAllLeftMenu() {
        List<SysMenu> allMenu = sysMenuMapper.findAll();
        List<SysMenu> menuList = allMenu.stream().filter(sysMenu -> {
            return sysMenu.getMenuType().equalsIgnoreCase("M")&&!"#".equalsIgnoreCase(sysMenu.getUrl());
        }).collect(Collectors.toList());
        return menuList;
    }
}
